


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > SpriteTest</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/idea.min.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.min.js"></script>
  <script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">nl.tudelft.jpacman.sprite</a>
</div>

<h1>Coverage Summary for Class: SpriteTest (nl.tudelft.jpacman.sprite)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">SpriteTest</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/10)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/17)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package nl.tudelft.jpacman.sprite;
&nbsp;
&nbsp;import static org.assertj.core.api.Assertions.assertThatThrownBy;
&nbsp;import static org.assertj.core.api.Assertions.assertThat;
&nbsp;
&nbsp;import java.io.IOException;
&nbsp;
&nbsp;import org.junit.jupiter.api.BeforeEach;
&nbsp;import org.junit.jupiter.api.Test;
&nbsp;
&nbsp;/**
&nbsp; * Verifies the loading of sprites.
&nbsp; *
&nbsp; * @author Jeroen Roosen 
&nbsp; */
&nbsp;@SuppressWarnings(&quot;magicnumber&quot;)
<b class="nc">&nbsp;public class SpriteTest {</b>
&nbsp;
&nbsp;    private Sprite sprite;
&nbsp;    private SpriteStore store;
&nbsp;
&nbsp;    private static final int SPRITE_SIZE = 64;
&nbsp;
&nbsp;    /**
&nbsp;     * The common fixture of this test class is
&nbsp;     * a 64 by 64 pixel white sprite.
&nbsp;     *
&nbsp;     * @throws java.io.IOException
&nbsp;     *      when the sprite could not be loaded.
&nbsp;     */
&nbsp;    @BeforeEach
&nbsp;    public void setUp() throws IOException {
<b class="nc">&nbsp;        store = new SpriteStore();</b>
<b class="nc">&nbsp;        sprite = store.loadSprite(&quot;/sprite/64x64white.png&quot;);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies the width of a static sprite.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void spriteWidth() {
<b class="nc">&nbsp;        assertThat(sprite.getWidth()).isEqualTo(SPRITE_SIZE);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies the height of a static sprite.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void spriteHeight() {
<b class="nc">&nbsp;        assertThat(sprite.getHeight()).isEqualTo(SPRITE_SIZE);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies that an IOException is thrown when the resource could not be
&nbsp;     * loaded.
&nbsp;     *
&nbsp;     * @throws java.io.IOException
&nbsp;     *             since the sprite cannot be loaded.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void resourceMissing() throws IOException {
<b class="nc">&nbsp;        assertThatThrownBy(() -&gt; store.loadSprite(&quot;/sprite/nonexistingresource.png&quot;))</b>
<b class="nc">&nbsp;            .isInstanceOf(IOException.class);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies that an animated sprite is correctly cut from its base image.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void animationWidth() {
<b class="nc">&nbsp;        AnimatedSprite animation = store.createAnimatedSprite(sprite, 4, 0,</b>
&nbsp;            false);
<b class="nc">&nbsp;        assertThat(animation.getWidth()).isEqualTo(16);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies that an animated sprite is correctly cut from its base image.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void animationHeight() {
<b class="nc">&nbsp;        AnimatedSprite animation = store.createAnimatedSprite(sprite, 4, 0,</b>
&nbsp;            false);
<b class="nc">&nbsp;        assertThat(animation.getHeight()).isEqualTo(64);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies that an split sprite is correctly cut from its base image.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void splitWidth() {
<b class="nc">&nbsp;        Sprite split = sprite.split(10, 11, 12, 13);</b>
<b class="nc">&nbsp;        assertThat(split.getWidth()).isEqualTo(12);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies that an split sprite is correctly cut from its base image.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void splitHeight() {
<b class="nc">&nbsp;        Sprite split = sprite.split(10, 11, 12, 13);</b>
<b class="nc">&nbsp;        assertThat(split.getHeight()).isEqualTo(13);</b>
&nbsp;    }
&nbsp;
&nbsp;    /**
&nbsp;     * Verifies that a split that isn&#39;t within the actual sprite returns an empty sprite.
&nbsp;     */
&nbsp;    @Test
&nbsp;    public void splitOutOfBounds() {
<b class="nc">&nbsp;        Sprite split = sprite.split(10, 10, 64, 10);</b>
<b class="nc">&nbsp;        assertThat(split).isInstanceOf(EmptySprite.class);</b>
&nbsp;    }
&nbsp;}
</code>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
      hljs.highlightAll()
      hljs.initLineNumbersOnLoad();
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2023-04-11 19:58</div>
</div>
</body>
</html>
